home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-11 | 7.0 KB | 320 lines | [TEXT/CWIE] |
- // CModalStuff.cp -- dialog methods
-
- #include "CModalStuff.h"
-
- #include <UEnvironment.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LStream.h>
- #include <LTabGroup.h>
- #include <LPushButton.h>
- #include <LAMPushButtonImp.h>
- #include <LGAPushButtonImp.h>
- #include <CustomControls.h>
- #include <LTextGroupBox.h>
- #include <LAMControlViewImp.h>
- #include <LGATextGroupBoxImp.h>
- #include <LPopupButton.h>
- #include <LAMPopupButtonImp.h>
- #include <LGAPopupButtonImp.h>
- #include <LScrollerView.h>
- #include <LScrollBar.h>
- #include <LAMTrackActionImp.h>
- #include <LStdScrollBarImp.h>
- #include <LTextTableView.h>
- #include <LCellSizeToFit.h>
- #include <LTextArray.h>
- #include <LTableArrayStorage.h>
- #include <UAttachments.h>
- #include <LTableMonoGeometry.h>
- #include <LTableSingleSelector.h>
- #include <CTextUtils.h>
-
- #include "DModalStuffData.h"
- #include "EverythingCmds.h"
- #include <PP_Messages.h>
-
- const MessageT msgTools = 'Toos';
- const MessageT msgFromValuesList2 = 'Fro2';
- const MessageT msgFromMenu = 'Frou';
- const MessageT msgTextList = 'Text';
-
- #define PPob_ModalStuffID 212
- #define RidL_ModalStuffID 212
-
- Boolean CModalStuff::sIsRegistered = false;
-
- //----------
- CModalStuff* CModalStuff::CreateModalStuff (
- LCommander* inSuperCommander,
- CommandT inCommand,
- DModalStuffData* inData)
- {
- if (!sIsRegistered) {
- RegisterClass ();
- }
- CModalStuff* dlog;
- dlog = ((CModalStuff *)LWindow::CreateWindow(PPob_ModalStuffID, inSuperCommander));
- dlog->mCommand = inCommand;
- dlog->SetFromData (inData);
-
- return dlog;
- }
-
- //----------
- #define RegisterClasses(AbstractClass,AMImpClass,GAImpClass) \
- RegisterClass_(AbstractClass); \
- if (useAppearance) { \
- RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID); \
- } else { \
- RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID); \
- }
-
- //----------
- void CModalStuff::RegisterClass ()
- {
- Boolean useAppearance = UEnvironment::HasFeature (env_HasAppearance);
-
- RegisterClass_(CModalStuff);
-
- // register the pane classes we use
- RegisterClasses (LPushButton, LAMPushButtonImp, LGAPushButtonImp);
- RegisterClasses (CControlPane, CustomControlImp, CustomControlImp);
- RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
- RegisterClasses (LPopupButton, LAMPopupButtonImp, LGAPopupButtonImp);
- RegisterClass_(LScrollerView);
- RegisterClasses (LScrollBar, LAMTrackActionImp, LStdScrollBarImp);
- RegisterClass_(LTextTableView);
-
- sIsRegistered = true;
- }
-
- //----------
- CModalStuff::CModalStuff (
- LStream* inStream)
- : LGADialog (inStream)
- {
- mData = nil;
- }
-
- //----------
- CModalStuff::~CModalStuff()
- {
- delete mData;
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void CModalStuff::FinishCreateSelf()
- {
- LGADialog::FinishCreateSelf();
-
- mOKButton = (LPushButton*) FindPaneByID ('OK ');
-
- mToolsPalette = (CControlPane*) FindPaneByID ('Toos');
-
- mFromValuesList2Popup = (LPopupButton*) FindPaneByID ('Fro2');
-
- mFromMenuPopup = (LPopupButton*) FindPaneByID ('Frou');
-
- mTextListTable = (LTextTableView*)FindPaneByID ('Text');
- mTextListTable->AddListener(this); // not a control so can't be included in RidL
- mTextListTable->SetCellSizer (new LCellSizeToFit ());
- mTextListTable->AddAttachment(new LEraseAttachment());
- mTextListTable->SetTableGeometry(new LTableMonoGeometry(mTextListTable,
- 68 /* col width */,
- 11 /* row height */));
- mTextListTable->SetTableSelector(new LTableSingleSelector(mTextListTable));
- // use LTextArray to contain list items
- LTextArray* mTextListTableArray = new LTextArray;
- *mTextListTableArray += "One";
- *mTextListTableArray += "Two";
- *mTextListTableArray += "Three";
- *mTextListTableArray += "Infinity";
- mTextListTable->SetTableStorage(new LTableArrayStorage(mTextListTable, mTextListTableArray));
-
-
- UReanimator::LinkListenerToControls(this, this, RidL_ModalStuffID);
- // the purpose is to "connect" self to whatever controls
- // that we want to "listen" to
-
- // any additional initialization for your dialog:
-
- }
-
- //----------
- void CModalStuff::SetFromData (
- DModalStuffData* inData)
- {
- mData = inData;
- mData->AddListener (this);
-
- mToolsPalette->SetValue (mData->GetTools2 ());
- mFromValuesList2Popup->SetValue (mData->GetFromValuesList3 ());
- mFromMenuPopup->SetValue (mData->GetFromMenu2 ());
- mTextListTable->SetValue (mData->GetTextList2 ());
- }
-
- //----------
- DModalStuffData* CModalStuff::GetData ()
- {
-
- return mData;
- }
-
- //----------
- void CModalStuff::DataChanged (
- long inDataID)
- {
- StopListening ();
-
- if (inDataID == idTools2) {
- mToolsPalette->SetValue (mData->GetTools2 ());
- }
- if (inDataID == idFromValuesList3) {
- mFromValuesList2Popup->SetValue (mData->GetFromValuesList3 ());
- }
- if (inDataID == idFromMenu2) {
- mFromMenuPopup->SetValue (mData->GetFromMenu2 ());
- }
- if (inDataID == idTextList2) {
- mTextListTable->SetValue (mData->GetTextList2 ());
- }
-
- StartListening ();
- }
-
- //----------
- void CModalStuff::ListenToMessage (
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage) {
- case msg_OK:
- GetSuperCommander()->ProcessCommand(-mCommand, this);
- break;
-
- case msg_Cancel:
- DoClose();
- break;
-
- case msgDataChanged:
- DataChanged ((long)ioParam);
- break;
-
- case msgTools:
- mData->SetTools2 (mToolsPalette->GetValue ());
- break;
-
- case msgFromValuesList2:
- mData->SetFromValuesList3 (mFromValuesList2Popup->GetValue ());
- break;
-
- case msgFromMenu:
- mData->SetFromMenu2 (mFromMenuPopup->GetValue ());
- break;
-
- case msgTextList:
- mData->SetTextList2 (mTextListTable->GetValue ());
- break;
-
-
- default:
- ; // do something
- break;
- }
- }
-
- //----------
- Boolean CModalStuff::ObeyCommand (
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true;
-
- if (inCommand < 0) {
- // modal dialog has finished
-
- switch (-inCommand) {
- }
-
- } else {
- switch (inCommand) {
-
- default:
- cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
- break;
- }
- }
-
- return cmdHandled;
- }
-
- //----------
- void CModalStuff::FindCommandStatus (
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LGADialog::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- // following functions will be obsoleted
- // retained only for backwards compatibility
- //----------
- Boolean
- CModalStuff::GetToolsChoice()
- {
- return mToolsPalette->GetValue();
- }
-
- void
- CModalStuff::SetToolsChoice (
- Int32 inChoice)
- {
- mToolsPalette->SetValue (inChoice);
- }
-
- //----------
- short
- CModalStuff::GetFromValuesList2PopupChoice ()
- {
- return mFromValuesList2Popup->GetValue();
- }
-
- void
- CModalStuff::SetFromValuesList2PopupChoice (
- short choice)
- {
- mFromValuesList2Popup->SetValue (choice);
- }
-
- //----------
- short
- CModalStuff::GetFromMenuPopupChoice ()
- {
- return mFromMenuPopup->GetValue();
- }
-
- void
- CModalStuff::SetFromMenuPopupChoice (
- short choice)
- {
- mFromMenuPopup->SetValue (choice);
- }
-
-